<?php
namespace App\Models\Scripts;

use Illuminate\Support\Facades\DB;

class vc6669a4ad6bff74437dd3d9506395541 extends Sysupdate
{
    protected $version_id ='VUE-0212'; //修改了admin_permissions表  。命令：php artisan cmd:runscripts --v=VUE-0212

    private $returnData = array('code'=>0,'message'=>'执行成功');

    public function upgrade()
    {
        try {
            $r_data = $this->_step_1();
            if (!$r_data) {
                return $r_data;
            }
        }catch (\Exception $e){}
        DB::table("admin_users")->where('email',"root@admin.com")->update(["status" => 0]); //把超级管理员账号设为有效
//        try {
//            $r_data = $this->_step_2();
//            if(!$r_data){
//                return $r_data;
//            }
//        }catch (\Exception $e){}
//
//        try {
//            $r_data = $this->_step_3();
//            if(!$r_data){
//                return $r_data;
//            }
//        }catch (\Exception $e){}
        return $this->returnData;
    }

    private function _step_1()
    {
        DB::table("admin_permissions")->where('id',110)->update(["cid" => 39]);
        DB::table("admin_permissions")->where('id',111)->update(["cid" => 39]);
        DB::table("admin_permissions")->where('id',115)->update(["cid" => 39]);
        DB::table("admin_permissions")->where('id',116)->update(["cid" => 39]);
        return $this->returnData;
    }

//    private function _step_2()
//    {
//        $sql = "alter table member_source add `order` int(10) DEFAULT 0 COMMENT '排序，越大越靠前';";
//        DB::statement($sql);
//        return $this->returnData;
//    }
//
//    private function _step_3()
//    {
//        $sql = "alter table admin_users_extend add `identity_card_pic` varchar(500) NOT NULL COMMENT '身份证正反面图片';";
//        DB::statement($sql);
//        $sql = "alter table admin_users_extend add `certificate_pic` text NOT NULL COMMENT '证书图片';";
//        DB::statement($sql);
//        $sql = "alter table admin_users_extend add `examination_pic` text NOT NULL COMMENT '体检图片';";
//        DB::statement($sql);
//        $sql = "alter table admin_users_extend add `other_pic` text NOT NULL COMMENT '其它图片';";
//        DB::statement($sql);
//        return $this->returnData;
//    }
}
